package model;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;

public class Bob {
	public enum State {
		IDLE, WALKING, JUMPING, DYING
	}
	public static final float SPEED = 2f; // unit per second
	static final float JUMP_VELOCITY= 1f;
	public static final float SIZE = 0.5f; //half an unit
	
	Vector2 position = new Vector2();
	Vector2 acceleration = new Vector2();
	Vector2 velocity = new Vector2();
	Rectangle bounds =new Rectangle();
	State state = State.IDLE;
	float stateTime=0;
	boolean isFacingleft = false;
	boolean longjump = false;
	boolean grounded =true;
	
	String soundJump = "sound/jump.mp3";
	//fire of bob
	Array <Bullet> bullets = new Array<Bullet>();
	public void setLongjump(boolean longjump){
		this.longjump=longjump;
	}
	public boolean isLongjump(){
		return longjump;
	}
	public void setFacingleft(boolean faceleft){
		isFacingleft=faceleft;
	}
	public boolean isFacingLeft(){
		return isFacingleft;
	}
	public Bob(Vector2 position)
	{
		this.position=position;
		this.bounds.x=position.x;
		this.bounds.y=position.y;
		this.bounds.height=SIZE;
		this.bounds.width=SIZE;
	}
	public Rectangle getBounds(){
		return bounds;
	}
	public Vector2 getPosition(){
		return position;
	}
	public void setPosition(Vector2 pos){
		this.position=pos;
		bounds.setX(pos.x);
		bounds.setY(pos.y);
		
	}
	public State getState(){
		return state;
	}
	public void setState(State newstate){
		this.state=newstate;
	}
	public void update (float delta){
		stateTime+=delta;
		//position.add(velocity.cpy().scl(delta));
	}
	public Vector2 getVelocity(){
		return velocity;
	}
	public Vector2 getAcceleration(){
		return acceleration;
	}
	public float getStateTime(){
		return stateTime;
	}
	public Array<Bullet> getFire(){
		return bullets;
	}
	public void Fire(){
		bullets.add(new Bullet(new Vector2(position.x+SIZE/2,position.y+SIZE/2),isFacingleft));
	}
	public void setGrounded(boolean ground){
		grounded = ground;
	}
	public boolean getGrounded(){
		return grounded;
	}
	public String getSoundJump(){
		return soundJump;
	}
}
